package com.whats.indicator.entity;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import com.whats.indicator.util.IConstant;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("t_zbkb_equip_assetst_f")
public class EquipAssetst {
    @MppMultiId
    @ExcelIgnore
    @JsonProperty("obj_id")
    private String objId;
    @MppMultiId
    @ExcelIgnore
    @JsonProperty("last_update_time")
    private LocalDateTime lastUpdateTime;

//    @TableId(type = IdType.NONE)
//    private EquipAssetstCompositeKey compositeKey;
    @ExcelIgnore
    @JsonProperty("province")
    private String province;
    @ExcelIgnore
    @JsonProperty("province_name")
    private String provinceName;
    @ExcelIgnore
    @JsonProperty("professional_type")
    private String professionalType;

    @ExcelProperty(index = 1, value = "专业类别")
    @TableField(exist = false)
    private String professionalTypeName;
    @ExcelIgnore
    @JsonProperty("psr_id")
    private String psrId;
    @ExcelIgnore
    @JsonProperty("ast_id")
    private String astId;
    @ExcelIgnore
    @JsonProperty("equip_type")
    private String equipType;
    @ExcelProperty(index = 2, value = "设备类型")
    @JsonProperty("equip_type_name")
    private String equipTypeName;
    @ExcelProperty(index = 0, value = "设备名称")
    @JsonProperty("name")
    private String name;
    @ExcelProperty(index = 7, value = "设备编码")
    @JsonProperty("equip_code")
    private String equipCode;
    @ExcelIgnore
    @JsonProperty("city")
    private String city;
    @ExcelProperty(index = 3, value = "所属地市")
    @JsonProperty("city_name")
    private String cityName;
    @ExcelIgnore
    @JsonProperty("maint_org")
    private String maintOrg;
    @ExcelProperty(index = 4, value = "运维单位")
    @JsonProperty("maint_org_name")
    private String maintOrgName;
    @ExcelIgnore
    @JsonProperty("maint_group")
    private String maintGroup;
    @ExcelProperty(index = 5, value = "运维班组")
    @JsonProperty("maint_group_name")
    private String maintGroupName;
    @ExcelIgnore
    @JsonProperty("ast_org")
    private String astOrg;
    @ExcelProperty(index = 9, value = "资产单位")
    @JsonProperty("ast_org_name")
    private String astOrgName;
    @ExcelIgnore
    @JsonProperty("psr_state")
    private String psrState;
    @ExcelProperty(index = 8, value = "实物ID")
    @JsonProperty("utc_num")
    private String utcNum;
    @ExcelProperty(index = 10, value = "资产编号")
    @JsonProperty("ast_num")
    private String astNum;
    @ExcelProperty(index = 11, value = "资产原值(元)")
    @JsonProperty("ast_original_value")
    private Double astOriginalValue;
    @ExcelProperty(index = 12, value = "资产净值(元)")
    @JsonProperty("ast_net_value")
    private Double astNetValue;
    @ExcelIgnore
    @JsonProperty("ast_category")
    private String astCategory;
    @ExcelProperty(index = 13, value = "资产大类")
    @JsonProperty("ast_category_name")
    private String astCategoryName;
    @ExcelIgnore
    @JsonProperty("voltage_level")
    private String voltageLevel;
    @ExcelProperty(index = 14, value = "电压等级")
    @TableField(exist = false)
    private String voltageLevelName;
    @ExcelIgnore
    @JsonProperty("ast_nature")
    private String astNature;
    @ExcelIgnore
    @JsonProperty("deploy_state")
    private String deployState;
    @ExcelProperty(index = 6, value = "设备状态")
    @TableField(exist = false)
    private String deployStateName;
    @ExcelProperty(index = 15, value = "出厂日期")
    @JsonProperty("manufacture_date")
    private LocalDateTime manufactureDate;
    @ExcelProperty(index = 16, value = "投运日期")
    @JsonProperty("operate_date")
    private LocalDateTime operateDate;
    @ExcelProperty(index = 17, value = "设备主人")
    @JsonProperty("equipment_owner")
    private String equipmentOwner;
    @ExcelProperty(index = 18, value = "技术寿命")
    @JsonProperty("technical_life")
    private Double technicalLife;

    @ExcelIgnore
    private LocalDateTime etlTm = LocalDateTime.now();


    public String getProfessionalTypeName() {
        if ("01".equals(professionalType)) {
            return "输电";
        }
        if ("02".equals(professionalType)) {
            return "变电";
        }
        if ("03".equals(professionalType)) {
            return "配电";
        }
        if ("05".equals(professionalType)) {
            return "通信";
        }
        if ("06".equals(professionalType)) {
            return "自动化";
        }
        return "其他";
    }

    public String getDeployStateName() {
        if ("10".equals(deployState)) {
            return "未投运";
        }
        if ("20".equals(deployState)) {
            return "在运";
        }
        if ("30".equals(deployState)) {
            return "退役";
        }
        if ("31".equals(deployState)) {
            return "现场留用";
        }
        if ("33".equals(deployState)) {
            return "待报废";
        }
        if ("40".equals(deployState)) {
            return "报废";
        }
        if ("50".equals(deployState)) {
            return "再利用";
        }
        if ("60".equals(deployState)) {
            return "备品备件";
        }
        if ("70".equals(deployState)) {
            return "调拨";
        }
        return "其他";
    }

    public String getVoltageLevelName() {
        String volName = IConstant.VOLTAGE_LEVEL_MAP.get(voltageLevel);
        if (StrUtil.isNotBlank(volName)) {
            return volName;
        }
        return "其他";
    }

}
